/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.inspur.edp.metadata.rtcustomization.context;

import com.inspur.edp.lcm.metadata.api.entity.GspMetadata;
import com.inspur.edp.metadata.rtcustomization.api.entity.ConfigDataDependenciesEnum;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import lombok.Data;

/**
 * 复制服务上下文
 */
@Data
public class MimicServiceContext {
    /**
     * key: 旧元数据ID value：复制后的元数据ID
     */
    private Map<String, String> oldUUID2NewUUIDMap;
    /**
     * key: 配置数据列变量 value：配置数据列新值
     */
    private Map<String, String> columnVariable2NewValueMap;
    /**
     * key：配置数据类型 value：被依赖的配置数据列表
     */
    private Map<ConfigDataDependenciesEnum, Set<String>> configDataDependenciesEnumListMap;
    /**
     * key: 原始元数据ID(复制前) value: 复制后的元数据
     */
    private Map<String, GspMetadata> originalMetadataId2GspMetadataAfterCopyMap;

    /**
     * 构造函数
     *
     * @param oldUUID2NewUUIDMap
     * @param columnVariable2NewValueMap
     * @param configDataDependenciesEnumListMap
     * @param originalMetadataId2GspMetadataAfterCopyMap
     */
    private MimicServiceContext(Map<String, String> oldUUID2NewUUIDMap,
                                Map<String, String> columnVariable2NewValueMap,
                                Map<ConfigDataDependenciesEnum, Set<String>> configDataDependenciesEnumListMap,
                                Map<String, GspMetadata> originalMetadataId2GspMetadataAfterCopyMap) {
        this.oldUUID2NewUUIDMap = oldUUID2NewUUIDMap;
        this.columnVariable2NewValueMap = columnVariable2NewValueMap;
        this.configDataDependenciesEnumListMap = configDataDependenciesEnumListMap;
        this.originalMetadataId2GspMetadataAfterCopyMap = originalMetadataId2GspMetadataAfterCopyMap;
    }

    public static MimicServiceContext ofMimicServiceContext() {
        Map<String, String> oldUUID2NewUUIDMap = new HashMap<>(16);
        Map<String, String> columnVariable2NewValueMap = new HashMap<>(128);
        Map<ConfigDataDependenciesEnum, Set<String>> configDataDependenciesEnumListMap = new HashMap<>(16);
        Map<String, GspMetadata> originalMetadataId2GspMetadataAfterCopyMap = new HashMap<>(64);
        return new MimicServiceContext(oldUUID2NewUUIDMap, columnVariable2NewValueMap, configDataDependenciesEnumListMap,
                originalMetadataId2GspMetadataAfterCopyMap);
    }
}
